package com.wx.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.wx.model.Sta;
import com.wx.serviceImpl.StaServiceImpl;

/**
 * Servlet implementation class FindStaServlet
 */
@WebServlet("/servlet/FindStaServlet")
public class FindStaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FindStaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String staId = request.getParameter("staid");
		String staName = request.getParameter("staname");
		String brand = request.getParameter("brand");
		String staType = request.getParameter("statype");
		Sta sta = new Sta();
		sta.setStaid(Integer.parseInt(staId));
		sta.setStaname(staName);
		sta.setBrand(brand);
		sta.setStatype(staType);
		try {
			List<Sta> stas = new StaServiceImpl().findSta(sta);
			System.out.println(stas.size());
			request.setAttribute("list",stas);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		request.getRequestDispatcher("../manage/sta.jsp").forward(request, response);;
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
